@extends('layouts.backend')
@section('title')
    添加后台菜单
@endsection

@section('body')
    <div class="row">
        <div class="ibox">
            <div class="ibox-title">
                <h5>添加后台菜单</h5>
                <a href="{{route('backend.menu.index')}}" class="btn btn-primary pull-right">返回列表</a>
                <div class="clearfix"></div>
            </div>
            <div class="ibox-content">

                <div class="row">
                    <div class="col-md-8">
                        <form method="post" class="form-horizontal" >
                            @csrf
                            <input type="hidden" name="_method" value="PUT">
                            <div class="form-group">
                                <label>父菜单</label>
                                <select name="parent_id" class="form-control">
                                    <option value="0">无父菜单</option>
                                    @foreach($menus as $menuItem)
                                        <option value="{{$menuItem->id}}" {{$menu->parent_id == $menuItem->id ? 'selected' : ''}}>{{$menuItem->name}}</option>
                                        @foreach($menuItem->children as $child)
                                            <option value="{{$child->id}}" disabled="disabled">|----{{$child->name}}</option>
                                        @endforeach
                                    @endforeach
                                </select>
                            </div>
                            <div class="form-group">
                                <label>排序 @include('components.backend.required')</label>
                                <input type="text" name="order" class="form-control" placeholder="排序" value="{{$menu->order}}" required>
                            </div>
                            <div class="form-group">
                                <label>链接名 @include('components.backend.required')</label>
                                <input type="text" name="name" class="form-control" placeholder="链接名" value="{{$menu->name}}" required>
                            </div>
                            <div class="form-group">
                                <label>链接地址 @include('components.backend.required')</label>
                                <input type="text" name="url" class="form-control" placeholder="链接地址" value="{{$menu->url}}" required>
                            </div>
                            <div class="form-group">
                                <label>关联权限 @include('components.backend.required')</label>
                                <select name="permission_id" class="form-control">
                                        <option value="0">无</option>
                                    @foreach($permissions as $permission)
                                        <option value="{{ $permission->name }}" {{$menu->permission_name == $permission->name ? 'selected' : ''}}>{{ $permission->display_name }}</option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2 pull-right">
                                    <button class="btn btn-primary" type="submit">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>

            </div>
        </div>
    </div>
@endsection
